/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package net.ytbolg.mcxa.gui.Lang_and_ConfigManager;

import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.ytbolg.mcxa.gui.General;
import sun.java2d.loops.CompositeType;

/**
 *
 * @author Ytong
 */
public class LangManager {

    //   ArrayList<String> list = new ArrayList<>();
    static ArrayList<Properties> langs = new ArrayList<>();
    static int now = 0;

    public static void Load(int id) {
        try {
            now = id;
        } catch (Exception e) {
        }
    }

    public static String getStringByKey(String Key) {
      String tmp=langs.get(now).getProperty(Key);
      if(tmp==null){
      General.Log("丢失的语言ID:"+Key+"，将使用默认",LangManager.class.getSimpleName());
      return Key;
      }
        return langs.get(now).getProperty(Key);
    }

    public static void addLangData(InputStream is) {
        Properties p = new Properties();
        try {
            p.load(is);
        } catch (IOException ex) {
            Logger.getLogger(LangManager.class.getName()).log(Level.SEVERE, null, ex);
        }
        langs.add(p);
    }

    public static String getNameById(int id) {
        return langs.get(id).getProperty("name");
    }

    /**
     *
     * @return 数量 从0开始
     */
    public static int size() {
        return langs.size();

    }
}
